package drrr.controller;

import drrr.orm.RoomEntity;
import org.apache.struts2.ServletActionContext;

import java.util.Map;


/**
 * Created by Two_Cong on 15/05/28.
 */
public class ChagRoomNameAction  extends BaseAction {
    private  String newRoomName;

    public String getNewRoomName() {
        return newRoomName;
    }

    public void setNewRoomName(String newRoomName) {
        this.newRoomName = newRoomName;
    }
    public  String execute() throws Exception{
        //获取room表中的信息
        RoomEntity roomEntity1=new RoomEntity();
        Map<String,Object> session= ServletActionContext.getContext().getSession();
        RoomEntity roomEntity=((RoomEntity)session.get("room"));
        roomEntity1.setRoomname(this.getNewRoomName());
        roomEntity1.setId(roomEntity.getId());
        roomEntity1.setCreateDate(roomEntity.getCreateDate());
        roomEntity1.setMembernum(roomEntity.getMembernum());
        roomEntity1.setOwner(roomEntity.getOwner());
        roomEntity1.setType(roomEntity.getType());
        getAllService().getRoomService().update(roomEntity1);
        session.put("room",roomEntity1);
        return SUCCESS;
    }
}
